/**
 * @file mainform.h
 * @brief MainForm class definition
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 3 of the License.
 *
 * @author VestniK (Sergey N.Vidyuk) sir.vestnik@gmail.com
 * @date 24 Jan 2009
 */
#ifndef _MainForm_H_
#define _MainForm_H_

#include "ui_mainform.h"

#include <QtCore/QtGlobal>
#include <QtCore/QString>
#include <QtGui/QMainWindow>
#include <QtGui/QLabel>

#include "serverthread.h"

#include "client.h"
#include "logviewer.h"
#include "mjntypes.h"

namespace mjn {

    class ConnectToHostDialog;
    class StartServerDialog;

    class MainForm: public QMainWindow, private Ui::MainForm {
        Q_OBJECT
        public:
            MainForm(QWidget *parent = 0);
            virtual ~MainForm();

            Client &client() {return mClient;}
            ServerThread &serverThread() {return mServerThread;}
        public slots:
            void connecting();
            void connected();
            void disconnected();
            void serverStarting();
            void serverStarted();
            void serverStopped();
        private slots:
            void on_actionConnect_activated();
            void on_actionStartServer_activated();
            void on_actionViewLogs_activated();
            void onConnectionError(const QString &msg);
            void onServerStarted();
            void onClientDisconnected();
            /// @todo move this slot intp another class which will be responsible
            /// for showing players list.
            void onUpdatePlayers(const QList<mjn::SessionInfo> &names);
        private:
            ConnectToHostDialog* mConnectionDialog;
            StartServerDialog *mServerDialog;
            LogViewer *mLogViewer;
            Client mClient;
            ServerThread mServerThread;
    };

}

#endif
